package com.integrance.budgetapp.domain;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "BUDGET")
public class Budget {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "budget_id", nullable = false, unique = true)
    private Long id;
    
    @Column(name = "label", nullable = false)
    private String label;
    
    @Column(name = "create_date", nullable = false)
    private Date createDate;
    
    @Column(name = "budget_timestamp")
    private Date timestamp;
    
    @ManyToOne
    @JoinColumn(name = "portfolio_id", nullable = false)
    private Portfolio portfolio;
    
    @ManyToMany
    @JoinTable(name = "BUDGET_EXPENSE")
    private Set<Expense> expenses;
    
    @ManyToMany
    @JoinTable(name = "BUDGET_INCOME")
    private Set<Income> incomes;
    
    
    public Budget() {}
    
    public Budget(String label, Date createDate, Portfolio portfolio) {
		this.createDate = createDate;
		this.label = label;
		this.portfolio = portfolio;
	}

	public Long getId() {
        return id;
    }

    private void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }
    
    public Portfolio getPortfolio() {
		return portfolio;
	}
    
    public void setPortfolio(Portfolio portfolio) {
		this.portfolio = portfolio;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
    
	public Set<Expense> getExpenses() {
		return expenses;
	}
	
	public void setExpenses(Set<Expense> expenses) {
		this.expenses = expenses;
	}
	
	public Set<Income> getIncomes() {
		return incomes;
	}
	
	public void setIncomes(Set<Income> incomes) {
		this.incomes = incomes;
	}
}
